<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios</title>
    <script src="../js/vue.js"></script>
    <script src="../js/axios.js"></script>
</head>
<body>
    <div id="app">
       <ul>
            <li v-for="(item, index) in newsList" :key="index" v-text="item.title"></li>
       </ul>

    </div>
</body>
<script>
    //定义请求拦截器
    axios.interceptors.request.use(function(request){
        request.headers.authenri="ninnn"
        return request;
    },function(error){
        return Promise.reject(error);   
    });


       //定义响应拦截器
       axios.interceptors.response.use(function(response){
        console.log(response)
        return response.data;
    },function(error){
        return Promise.reject(error);   
    });


    new Vue({
        el:"#app",
        data:{
           inputStr:undefined,
           count:0,
           newsList:[
               
            ],
        },
        methods: {
           loadList(){
                let that = this;
           
                axios.get("../js/news.json").then(response=>{
                    // debugger
                    console.log(response);
                    that.newsList=response
                    
                });
           }
        },
        beforeCreate() {
            console.log("进入beforeCreate钩子")
            // debugger
            
        },
        created() {
            console.log("进入created钩子")
            // debugger
        },
        beforeMount() {
            console.log("进入beforeMount钩子")
            // debugger
        },
        mounted() {
            console.log("进入mounted钩子")
            // debugger
            this.loadList();
        },
        beforeUpdate() {
            console.log("进入beforeUpdate钩子")
        },
        updated() {
            // this.changeInputStr();
            console.log("进入updated钩子")
        },
        beforeDestroy() {
            console.log("进入beforeDestroy钩子")
        },
        destroyed() {
            console.log("进入destroyed钩子")
        },

    });


</script>
</html>